<%@ page import="java.sql.*,pc.util.Utils"%>
<%
    Users user = Trader.getUser(request.getParameter("uid"));
	wstrader.task.trade.physical.Contract task = user.trade.physical.contract;

	if (!user.Authenticated()) {
		response.sendRedirect("logon.jsp");
		return;
	}
	((Tasks)task.getOwner()).clearFocus();
	task.setFocus(true);	
	Trader.window_width = "90%";
	long focused_id =0;
	ResultSet rs;
%>
<%@include file="../header.jsp"%>

<%
	focused_id = task.doTask();	
	Record rc   = task.getRecord("contracts",focused_id);
	Record rcQR = new Record(task.getWhseReceiptQualityReport());	
	Record rcC = new Record(task.getContractDiscAllowDetails());	
	Record rcWR = new Record(task.getWhseReceiptDetails());		
	Record rcP = new Record(task.getPaymentDetails());
	rcP.beforeFirst();
	float pMrkPrice =0;
	float pPrvPrice =0;
	float pDiff=0;
	float pExRt =0;
	float pPhysDiscMt =0;
	float pPhysDiscV=0;
	float pCupTest=0;
	float pStorage=0;
	float pInt =0;
	float pOth =0;
	float pTotDisc =0;
	float pPaid =0;
	
	String WhDt = "";
	rcWR.beforeFirst();
	if (rcWR.next()==true)
	{
		WhDt = rcWR.getDate("date");
	}
	else
	{
		WhDt ="";
	}
	if (rcP.next() == true)
	{
	  	pMrkPrice =rcP.getFloatValue("market_price");
		pPrvPrice =rcP.getFloatValue("provisional_price") * rcP.getFloatValue("exchange_rate");
		pDiff=rcP.getFloatValue("differential");
		pExRt =rcP.getFloatValue("exchange_rate");
		pPhysDiscMt =rcP.getFloatValue("physical_discount_percentage");
		pPhysDiscV=rcP.getFloatValue("physical_discount_value") * rcP.getFloatValue("exchange_rate");
		pCupTest=rcP.getFloatValue("cuptest_discount");
		pStorage=rcP.getFloatValue("storage_discount");
		pInt =rcP.getFloatValue("interest_discount");
		pOth =rcP.getFloatValue("other_discount");
		pTotDisc =rcP.getFloatValue("total_discount_value");
		pPaid =rcP.getFloatValue("paid_value_foreign");
	}
	else
	{
	  	pMrkPrice =0;
		pPrvPrice =0;
		pDiff=0;
		pExRt =0;
		pPhysDiscMt =0;
		pPhysDiscV=0;
		pCupTest=0;
		pStorage=0;
		pInt =0;
		pOth =0;
		pTotDisc =0;
		pPaid =0;
	}
%>
<style type="text/css">
<!--
.style1 {
	font-family: Arial;
	font-size: 12px;
}
.style2 {font-size: 12px}
.style3 {font-weight: bold}
.style4 {font-family: Arial; font-size: 12px; font-weight: bold; }
-->
</style>

<script language="javascript">

function doCalPrvPrice()
{
	var form = document.formMain;
	var mrkprice =0;
	var diff=0;
	var netmrkprice =0;
	var totaldiscount = 0;
	var delvytons =0;
	var delvy_value =0;
	
	var cuptestdisc = 0;
	var intdisc =0;
	var storagedisc =0;
	var otherdisc =0;
	
	var exrt =0;
	
	exrt = form.exchange_rate.value * 1;
	
	totaldiscount = form.discount_percentage.value * 1;
	delvytons = form.tons_delivered.value;
	
	cuptestdisc = form.cuptest_discount.value * -1;
	cuptestdisc = (cuptestdisc * delvytons);
	
	storagedisc = form.storage_discount.value * -1;
	storagedisc = (storagedisc * delvytons);
	
	intdisc = form.interest_discount.value * -1;
	intdisc = (intdisc * delvytons);
	
	otherdisc = form.other_discount.value * -1;
	otherdisc = (otherdisc * delvytons);
	
	if (form.contract_price_type.value == "U")
	{
		if (form.unfixed_tons.value > 0)
		{
			var ppp=form.provisional_price_percentage.value;
			mrkprice = form.market_price.value * 1;
			diff = form.differential.value * 1;	
			netmrkprice = mrkprice + diff;
			discountmt = ((((netmrkprice * ppp)/100) * totaldiscount )/100)* exrt;
			form.net_mrk_price.value = formatNumber(netmrkprice * exrt,2,false);
			form.provisional_price.value = ((netmrkprice * ppp)/100) * exrt * 1;
			delvy_value = (((netmrkprice*ppp)/100) * delvytons * exrt) * 1;
		}
		else
		{
			netmrkprice = (form.contract_price.value) * 1;
			discountmt = ((netmrkprice * totaldiscount)/100)* exrt;		
			delvy_value = (netmrkprice * delvytons * exrt) * 1;
			form.contract_price_foreign.value = netmrkprice* exrt;
			form.contract_price_value.value = (netmrkprice * exrt) * delvytons;			
		}
	}
	else
	{
		netmrkprice = (form.contract_price.value) * 1;
		discountmt = ((netmrkprice * totaldiscount)/100)* exrt;
		delvy_value = (netmrkprice * delvytons * exrt) * 1;
		form.contract_price_foreign.value = netmrkprice* exrt;
		form.contract_price_value.value = (netmrkprice * exrt) * delvytons;		
	}

	form.discount_mt.value =  formatNumber(discountmt,2,false);
	form.physical_discount.value = formatNumber((discountmt *  delvytons),2,false);
	
	var phydisc = 0;
	phydisc = form.physical_discount.value;
	var totdisc = 0;
	totdisc = (discountmt*1) + (storagedisc*1) + (cuptestdisc*1) + (intdisc*1) + (otherdisc*1);
	form.total_discount.value =  formatNumber(totdisc,2,false);
	form.amount_paid.value = (delvy_value + (totdisc * delvytons))*1;
}

function doUpdatePay()
{
	var form = document.formMain;
	
	if (form.warehouse_receipt.value > 0)
	{
		if (form.exchange_rate.value > 0)
		{
			doTask(6);
		}
		else
		{
			alert("Exchange rate cannot be zero");
		}
	}
	else
	{
		alert("Select warehouse receipt");
	}
}

function doPricConfirmRpt()
{
	var form = document.formMain;
	if (form.warehouse_receipt.value > 0)
	{
		if (form.exchange_rate.value > 0)
		{
			doTask(7);
		}
		else
		{
			alert("Exchange rate cannot be zero");
		}
	}
	else
	{
		alert("Select warehouse receipt");
	}
			
}

function doListView()
{
	var form = document.formMain;
	form.action = "trade.physical.jsp";
	form.submit();
}

function doFinal()
{
	var form = document.formMain;
	if (form.contract_price_type.value == 'U')
	{
		if (form.unfixed_tons.value == 0)
		{
			doTask(8);
		}
		else
		{
			alert("you cannot print a final payment when the contract is not fully fixed");
		}
	}
	else
	{
		alert("you cannot print a final payment for outright contract");
	}
			

}
</script>
<form action="" method="post" name="formMain" id="formMain">
  <table width="100%"  border="0.5" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan="3"><img src="images/contract-priceconfirmation.jpg" width="400" height="30"></td>
      <td width="43%"><span class="style3">
        <input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">
        <input type="hidden" name="task_id"    id = "task_id"   value="0">
        <span class="style1">
        <input name="unfixed_tons" type="hidden" id="unfixed_tons" value="<%=rc.getFloatValue("unfixed_tons")%>">
        <input name="fixed_tons" type="hidden" id="fixed_tons" value="<%=rc.getFloatValue("fixed_tons")%>">
        <input name="contract_price_type" type="hidden" id="contract_price_type" value="<%=rc.getString("contract_price_type")%>">
        <span class="style4">        <input name="id" type="hidden" id="id" value="<%=rcP.getIntValue("id")%>">
</span> </span> </span></td>
      <td width="17%">&nbsp;</td>
    </tr>
    <tr>
      <td width="4%">&nbsp;</td>
      <td width="10%">&nbsp;</td>
      <td width="26%">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="5"><table width="100%"  border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td width="24%" valign="top"><table width="100%"  border="1" cellspacing="0" cellpadding="0" bordercolor="EEEEEEE">
            <tr>
              <td height="39" align="center" valign="middle" bgcolor="#DDDDDD"><strong><span class="style1">Contract No </span></strong></td>
              <td align="center" valign="middle" bgcolor="#DDDDDD" class="style1"><strong>Warehouse Receipt </strong></td>
            </tr>
            <tr>
              <td><select name="contracts" size="27" class="style2" id="contracts" style="width:160px; border:0" onChange="doPost();">
                <%@include file="include/ContractRefNoList.jsp"%>
              </select></td>
			  
              <td><select name="warehouse_receipt" size="27" class="style2" id="warehouse_receipt" style="width:160px; border:0" onChange="doPost();">
                <%@include file="include/WarehouseRefNoList.jsp"%>
              </select></td>

            </tr>
            <tr>
              <td colspan="2">&nbsp;</td>
              </tr>
          </table></td>
          <td width="76%" valign="top"><table width="100%"  border="1" cellspacing="0" cellpadding="0" bordercolor="EEEEEE">
            <tr>
              <td width="57%" align="left" valign="top"><table width="100%"  border="1" cellspacing="0" cellpadding="0" bordercolor="EEEEEE">
                <tr>
                  <td width="25%" height="31">&nbsp;</td>
                  <td width="11%" align="center" valign="middle" class="style1 style3">Actual %</td>
                  <td width="13%" align="center" valign="middle" class="style4">Allowed % </td>
                  <td width="12%" align="center" valign="middle" class="style4">Diff % </td>
                  <td width="13%" align="center" valign="middle" class="style4">Discount % </td>
                  <td width="13%" align="center" valign="middle" class="style4">Premium % </td>
                  <td width="13%" align="center" valign="middle" class="style4">Total % </td>
                </tr>
                <tr>
				  <%
				  	double adj = 0.2;
				  	double diff =0;
				  	diff = rcQR.getFloatValue("black") - rcC.getFloatValue("black_allowance");
					double disc = 0;
					double prem = 0;
					double tot = 0;
					double gtot = 0;
					
					double act18=0;
					double act16=0;
					double act14=0;
					double act13=0;
					double act12=0;
					double actb12=0;
										
					if (diff < 0)
					{
					 	prem = rcC.getFloatValue("black_premium");
						tot = (diff * prem)/100;
					}
					if (diff > 0) 
					{
						disc = rcC.getFloatValue("black_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Black</td>
                  <td align="center" valign="middle"><input name="black_actual" type="text" id="black_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("black"),2)%>"></td>
                  <td align="center" valign="middle"><input name="black_allowance" type="text" id="black_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("black_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="black_i_f" type="text" id="black_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="black_discount" type="text" id="black_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="black_premium" type="text" id="black_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="black_total" type="text" id="black_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("broken") - rcC.getFloatValue("broken_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0) 
					{	
						prem = rcC.getFloatValue("broken_premium");
						tot = (diff * prem)/100;
					}
					if (diff > 0) 
					{
						disc = rcC.getFloatValue("broken_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>						
                  <td height="29" align="right" class="style1">Broken</td>
                  <td align="center" valign="middle"><input name="broken_actual" type="text" id="broken_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("broken"),2)%>"></td>
                  <td align="center" valign="middle"><input name="broken_allowance" type="text" id="broken_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("broken_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="broken_i_f" type="text" id="broken_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="broken_discount" type="text" id="black_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="broken_premium" type="text" id="black_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="broken_total" type="text" id="broken_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("black_broken") - rcC.getFloatValue("blk_brk_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0)
					{
						 prem = rcC.getFloatValue("blk_brk_premium");
						 tot = (diff * prem)/100;
					}
					if (diff > 0)
					{
					 	disc = rcC.getFloatValue("blk_brk_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Black &amp; Broken </td>
                  <td align="center" valign="middle"><input name="blk_brk_actual" type="text" id="blk_brk_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("black_broken"),2)%>"></td>
                  <td align="center" valign="middle"><input name="blk_brk_allowance" type="text" id="blk_brk_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("blk_brk_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="blk_brk_i_f" type="text" id="black_i_f3" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="blk_brk_discount" type="text" id="broken_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="blk_brk_premium" type="text" id="broken_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="blk_brk_total" type="text" id="blk_brk_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("brown") - rcC.getFloatValue("brown_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0)
					{
						 prem = rcC.getFloatValue("brown_premium");
						 tot = (diff * prem)/100;
					}
					if (diff > 0) 
					{
						disc = rcC.getFloatValue("brown_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Brown</td>
                  <td align="center" valign="middle"><input name="brown_actual" type="text" id="brown_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("brown"),2)%>"></td>
                  <td align="center" valign="middle"><input name="brown_allowance" type="text" id="brown_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("brown_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="brown_i_f" type="text" id="black_i_f4" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="brown_discount" type="text" id="browm_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="brown_premium" type="text" id="brown_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="brown_total" type="text" id="brown_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("moldy") - rcC.getFloatValue("moldy_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0.2)
					{
						 prem = rcC.getFloatValue("moldy_premium");
						 tot = (diff * prem)/100;
					}
					if (diff > 0.2) 
					{
						diff = diff -adj;
						System.out.println("Diff:-" + adj);
						disc = rcC.getFloatValue("moldy_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				

                  <td height="29" align="right" class="style1">Moldy</td>
                  <td align="center" valign="middle"><input name="moldy_actual" type="text" id="moldy_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("moldy"),2)%>"></td>
                  <td align="center" valign="middle"><input name="moldy_allowance" type="text" id="moldy_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("moldy_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="moldy_i_f" type="text" id="black_i_f5" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="moldy_discount" type="text" id="moldy_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="moldy_premium" type="text" id="moldy_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="moldy_total" type="text" id="moldy_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("excelsa") - rcC.getFloatValue("excelsa_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0) 
					{
						prem = rcC.getFloatValue("excelsa_premium");
						tot = (diff * prem)/100;
					}
					if (diff > 0) 
					{
						disc = rcC.getFloatValue("excelsa_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Excelsa</td>
                  <td align="center" valign="middle"><input name="excelsa_actual" type="text" id="excelsa_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("excelsa"),2)%>"></td>
                  <td align="center" valign="middle"><input name="excelsa_allowance" type="text" id="excelsa_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("excelsa_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="excelsa_i_f" type="text" id="excelsa_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="excelsa_discount" type="text" id="excelsa_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="excelsa_premium" type="text" id="excelsa_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="excelsa_total" type="text" id="excelsa_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("foreign_matter") - rcC.getFloatValue("foreign_matter_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0)
					{
						 prem = rcC.getFloatValue("foreign_matter_premium");
						 tot = (diff * prem)/100;
					}
					if (diff > 0) 
					{
						disc = rcC.getFloatValue("foreign_matter_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Foreign Matter </td>
                  <td align="center" valign="middle"><input name="foreign_matter_actual" type="text" id="foreign_matter_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("foreign_matter"),2)%>"></td>
                  <td align="center" valign="middle"><input name="foreign_matter_allowance" type="text" id="foreign_matter_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("foreign_matter_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="foreign_matter_i_f" type="text" id="foreign_matter_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="foreign_matter_discount" type="text" id="foreign_matter_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="foreign_matter_premium" type="text" id="foreign_matter_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="foreign_matter_total" type="text" id="foreign_matter_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = rcQR.getFloatValue("moisture") - rcC.getFloatValue("moisture_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff < 0) 
					{
						prem = rcC.getFloatValue("moisture_premium");
						tot = (diff * prem)/100;
					}
					if (diff > 0) 
					{
						disc = rcC.getFloatValue("moisture_discount");
						tot = ((diff * disc)/100)*-1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Moisture</td>
                  <td align="center" valign="middle"><input name="moisture_actual" type="text" id="moisture_actual" style="width:40px" value="<%=Utils.numberToStr(rcQR.getFloatValue("moisture"),2)%>"></td>
                  <td align="center" valign="middle"><input name="moisture_allowance" type="text" id="moisture_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("moisture_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="moisture_i_f" type="text" id="black_i_f8" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="moisture_discount" type="text" id="moisture_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="moisture_premium" type="text" id="moisture_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="moisture_total" type="text" id="moisture_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
                  <td align="right" class="style1">&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                </tr>
                <tr>
				  <%
				  		 System.out.println("GrdId:-" + rc.getIntValue("grade_id"));
				  		 if (rc.getIntValue("grade_id") ==12)
						 {
						 	act18 = rcQR.getFloatValue("sc18")+rcQR.getFloatValue("sc19")+rcQR.getFloatValue("sc20")+rcQR.getFloatValue("above_sc20");
							act16 = 0;
							if ((rcQR.getFloatValue("sc13")+rcQR.getFloatValue("sc12")+rcQR.getFloatValue("below_sc12")) ==0)
							{
								act14 = 100;
							}
							else
							{
								act14 = 100-(rcQR.getFloatValue("sc13")+rcQR.getFloatValue("sc12")+rcQR.getFloatValue("below_sc12"));
							}
							act13=0;
							act12=0;
							actb12=0;
						 }
						 if (rc.getIntValue("grade_id") ==9)
						 {
						 	act18=0;
						 	act16 = rcQR.getFloatValue("sc16")+rcQR.getFloatValue("sc17")+rcQR.getFloatValue("sc18")+rcQR.getFloatValue("sc19")+rcQR.getFloatValue("sc20")+rcQR.getFloatValue("above_sc20");
							act14=0;
							if ((rcQR.getFloatValue("sc12")+rcQR.getFloatValue("below_sc12")) ==0)
							{
								act13 = 100;
							}
							else
							{
								act13 = 100-(rcQR.getFloatValue("sc12")+rcQR.getFloatValue("below_sc12"));
							}
							act12=0;
							actb12=0;						 
						 }
						 if (rc.getIntValue("grade_id") ==18)
						 {
						 	act18=0;
							act16=0;
							act14=0;
						 	act13 = rcQR.getFloatValue("sc13")+rcQR.getFloatValue("sc14")+rcQR.getFloatValue("sc16")+rcQR.getFloatValue("sc17")+rcQR.getFloatValue("sc18")+rcQR.getFloatValue("sc19")+rcQR.getFloatValue("sc20")+rcQR.getFloatValue("above_sc20");
							if ((rcQR.getFloatValue("sc12")+rcQR.getFloatValue("below_sc12")) <=10)
							{
								act12 = 10;
							}
							else
							{
								act14 = 10-(rcQR.getFloatValue("sc12")+rcQR.getFloatValue("below_sc12"));
							}
							act13=0;
							act12=0;
							actb12=0;							 
						 }						 
				  %>	
				  <%
				  	diff = (act18) - rcC.getFloatValue("sc18_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff > 0) 
					{
						prem = rcC.getFloatValue("sc18_premium");
						tot = ((diff * prem)/100) *-1;
					}
					if (diff < 0) 
					{
						disc = rcC.getFloatValue("sc18_discount");
						tot = ((diff * disc)/100)*1;
					}
					gtot  = gtot + tot;
				  %>					  
                  <td height="29" align="right" class="style1">Screen 18 </td>
                  <td align="center" valign="middle"><input name="sc18_actual" type="text" id="sc18_actual" style="width:40px" value="<%=Utils.numberToStr(act18,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc18_allowance" type="text" id="sc18_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("sc18_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="sc18_i_f" type="text" id="sc18_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc18_discount" type="text" id="sc18_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc18_premium" type="text" id="sc18_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc18_total" type="text" id="sc18_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = (act16) - rcC.getFloatValue("sc16_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff > 0) 
					{
						prem = rcC.getFloatValue("sc16_premium");
						tot = ((diff * prem)/100)*-1;
					}
					if (diff < 0) 
					{
						disc = rcC.getFloatValue("sc16_discount");
						tot = ((diff * disc)/100)*1;
					}
					gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Screen 16 </td>
                  <td align="center" valign="middle"><input name="sc16_actual" type="text" id="sc16_actual" style="width:40px" value="<%=Utils.numberToStr(act16,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc16_allowance" type="text" id="sc16_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("sc16_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="sc16_i_f" type="text" id="sc16_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc16_discount" type="text" id="sc16_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc16_premium" type="text" id="sc16_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc16_total" type="text" id="sc16_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = (act14) - rcC.getFloatValue("sc14_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff > 0) 
					{
						prem = rcC.getFloatValue("sc14_premium");
						tot = ((diff * prem)/100)*-1;
					}
					if (diff < 0) 
					{
						disc = rcC.getFloatValue("sc14_discount");
						tot = ((diff * disc)/100)*1;
					}
					 gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Screen 14 </td>
                  <td align="center" valign="middle"><input name="sc14_actual" type="text" id="sc14_actual" style="width:40px" value="<%=Utils.numberToStr(act14,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc14_allowance" type="text" id="sc14_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("sc14_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="sc14_i_f" type="text" id="black_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc14_discount" type="text" id="sc14_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc14_premium" type="text" id="sc14_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc14_total" type="text" id="sc14_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = act13 - rcC.getFloatValue("sc13_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff > 0) 
					{
						prem = rcC.getFloatValue("sc13_premium");
						tot = ((diff * prem)/100)*-1;
					}
					if (diff < 0) 
					{
						disc = rcC.getFloatValue("sc13_discount");
						tot = ((diff * disc)/100)*1;
					}
					 gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Screen 13</td>
				  <%System.out.println("Sc13:-" + rcQR.getFloatValue("sc13"));%>
                  <td align="center" valign="middle"><input name="sc13_actual" type="text" id="sc13_actual" style="width:40px" value="<%=Utils.numberToStr(act13,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc13_allowance" type="text" id="sc13_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("sc13_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="sc13_i_f" type="text" id="sc13_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc13_discount" type="text" id="sc13_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc13_premium" type="text" id="sc13_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc13_total" type="text" id="sc13_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = act12 - rcC.getFloatValue("sc12_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff > 0) 
					{
						prem = rcC.getFloatValue("sc12_premium");
						tot = ((diff * prem)/100)*-1;
					}
					if (diff < 0) 
					{
						disc = rcC.getFloatValue("sc12_discount");
						tot = ((diff * disc)/100)*1;
					}
					 gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Screen 12</td>
                  <td align="center" valign="middle"><input name="sc12_actual" type="text" id="sc12_actual" style="width:40px" value="<%=Utils.numberToStr(act12,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc12_allowance" type="text" id="sc12_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("sc12_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="sc12_i_f" type="text" id="sc12_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc12_discount" type="text" id="sc12_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc12_premium" type="text" id="sc12_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="sc12_total" type="text" id="sc12_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
				  <%
				  	diff = actb12 - rcC.getFloatValue("below_sc12_allowance");
					disc = 0;
					prem = 0;
					tot = 0;
					if (diff > 0) 
					{
						prem = rcC.getFloatValue("below_sc12_premium");
						tot = ((diff * prem)/100)*-1;
					}
					if (diff < 0) 
					{
						disc = rcC.getFloatValue("below_sc12_discount");
						tot = ((diff * disc)/100)*1;
					}
					 gtot = gtot + tot;
				  %>				
                  <td height="29" align="right" class="style1">Below Screen 12 </td>
                  <td align="center" valign="middle"><input name="below_sc12_actual" type="text" id="below_sc12_actual" style="width:40px" value="<%=Utils.numberToStr(actb12,2)%>"></td>
                  <td align="center" valign="middle"><input name="below_sc12_allowance" type="text" id="below_sc12_allowance" style="width:40px" value="<%=Utils.numberToStr(rcC.getFloatValue("below_sc12_allowance"),2)%>"></td>
				  <td align="center" valign="middle"><input name="below_sc12_i_f" type="text" id="below_sc12_i_f" style="width:40px" value="<%=Utils.numberToStr(diff,2)%>"></td>
                  <td align="center" valign="middle"><input name="below_sc12_discount" type="text" id="below_sc12_discount" style="width:40px" value="<%=Utils.numberToStr(disc,2)%>"></td>
                  <td align="center" valign="middle"><input name="below_sc12_premium" type="text" id="below_sc12_premium" style="width:40px" value="<%=Utils.numberToStr(prem,2)%>"></td>
                  <td align="center" valign="middle"><input name="below_sc12_total" type="text" id="below_sc12_total" style="width:40px" value="<%=Utils.numberToStr(tot,2)%>"></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">Total Discount </td>
				 
                  <td align="center" valign="middle"><input name="discount_percentage" type="text" id="discount_percentage" style="width:40px" value="<%=Utils.numberToStr(gtot,2)%>"></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">Tons Delivered </td>
                  <td align="center"><input name="tons_delivered" type="text" id="tons_delivered" style="width:40px" value="<%=Utils.numberToStr((rcWR.getFloatValue("net_weight")/1000),2)%>"></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                  <td align="center">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                  <td align="center">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                  <td align="center">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                  <td align="center">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                  <td align="center">&nbsp;</td>
                </tr>
              </table></td>
              <td width="43%" align="left" valign="top"><table width="100%"  border="1" cellspacing="0" cellpadding="0" bordercolor="EEEEEE">
                <tr>
                  <td height="32" align="right" class="style1">Delivery Date</td>
                  <td align="center" class="style1">:</td>
                  <td align="right" class="style1"><input name="delivery_date" type="text" id="delivery_date" value="<%=WhDt%>"date")%" style="width:110px" readonly="true">                    </td>
                  <td align="right" class="style1"><img src="js/calendar.gif" width="20" height="20" onClick="popUpCalendar(this,'delivery_date','dd-mmm-yy');"></td>
                </tr>
                <tr>
                  <td height="32" align="right" class="style1">Exchange Rate</td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="exchange_rate" type="text" id="exchange_rate" value="<%=pExRt%>" style="width:140px" onChange="doCalPrvPrice()"></td>
                </tr>
                <tr>
                  <td height="32" align="right" class="style1">&nbsp;</td>
                  <td align="center" class="style1">&nbsp;</td>
                  <td colspan="2" align="right" class="style1">&nbsp;</td>
                </tr>
                <tr>
                  <td width="55%" height="32" align="right" class="style1">Contract Tons</td>
                  <td width="3%" align="center" class="style1">:</td>
                  <td width="42%" colspan="2" align="right" class="style1"><input name="contract_tons" type="text" id="contract_tons" value=<%=Utils.numberToStr(rc.getFloatValue("tons"),3)%> style="width:140px" readonly="true"></td>
                </tr>
                <tr>
                  <td height="30" align="right" class="style1">                      Received Tons </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="receive_tons" type="text" id="receive_tons" value=<%=Utils.numberToStr(rc.getFloatValue("receive_tons"),3)%> style="width:140px" readonly="true">                    </td>
                </tr>
                <tr>
                  <td height="30" align="right" class="style1">Balance Tons </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="pending_tons" type="text" id="pending_tons" value=<%=Utils.numberToStr(rc.getFloatValue("pending_tons"),3)%> style="width:140px" readonly="true">                    </td>
                </tr>
				<%
					String lblCntPerTonValue="";
					String lblCntValue="";
					String lblPhyDiscTonValue="";
					String lblPhyDiscValue="";
					String lblStkDiscTonValue="";
					String lblIntDiscTonValue="";
					String lblCupDiscTonValue="";
					String lblOthDiscTonValue="";
					String lblTotDiscValue="";
					String lblTotPaidForCntValue="";
					String lblTotDiscForCntValue="";
					
					if (rc.getIntValue("quality_id") == 2)
					{
						lblCntPerTonValue = "Contract Price (Dong/Mt)";
						lblCntValue = "Contract Value (Dong)";
						
						lblPhyDiscTonValue = "Physical Discount (Dong/Mt)";
						lblPhyDiscValue="Total Physical Discount (Dong)";
						
						lblStkDiscTonValue="Storage Discount (Dong/Mt)";
						lblIntDiscTonValue="Interest Discount (Dong/Mt)";
						lblCupDiscTonValue="Cuptest Discount (Dong/Mt)";
						lblOthDiscTonValue="Other Discount (Dong/Mt)";						
						
						lblTotDiscValue="Total Discount (Dong/Mt)";
						
						lblTotPaidForCntValue = "Total Amount Paid For The Contract (Dong)";
						lblTotDiscForCntValue = "Total Discount / Premium adj for the Contract (Dong)";
						
					}
					else
					{
						lblCntPerTonValue = "Contract Price (Dong/Mt)";
						lblCntValue = "Contract Value (Dong)";
						
						lblPhyDiscTonValue = "Physical Discount (Dong/Mt)";
						lblPhyDiscValue="Total Physical Discount (Dong)";
						
						lblStkDiscTonValue="Storage Discount (Dong/Mt)";
						lblIntDiscTonValue="Interest Discount (Dong/Mt)";
						lblCupDiscTonValue="Cuptest Discount (Dong/Mt)";
						lblOthDiscTonValue="Other Discount (Dong/Mt)";						
						
						lblTotDiscValue="Total Discount (Dong/Mt)";
						
						lblTotPaidForCntValue = "Total Amount Paid For The Contract (Dong)";
						lblTotDiscForCntValue = "Total Discount / Premium adj for the Contract (Dong)";
					}
				%>
                <tr>
                  <td height="27" align="right" class="style1"><input name="contract_price" type="hidden" id="contract_price" value="<%=rc.getFloatValue("contract_price_foreign")%>">                    <%=lblCntPerTonValue%></td>
                  <td align="center" class="style1">:</td>
				  <%
				  	 float CntPriceForeign=0;
					 if (rc.getFloatValue("unfixed_tons") == 0)
					 {
					 	CntPriceForeign = rc.getFloatValue("Contract_price_foreign") * rcP.getFloatValue("exchange_rate");
					 }
				  %>
                  <td colspan="2" align="right" class="style1"><input name="contract_price_foreign" type="text" id="contract_price_foreign" value=<%=Utils.numberToStr(CntPriceForeign,3,false)%> style="width:140px" readonly="true">                    </td>
                </tr>
                <tr>
                  <td height="30" align="right" class="style1"><%=lblCntValue%></td>
                  <td align="center" class="style1">:</td>
				  <%
				  	float CntValue = 0;
				  	if (rc.getFloatValue("unfixed_tons") == 0)
					{
				  		CntValue = rc.getFloatValue("tons") * (rc.getFloatValue("contract_price_foreign") * rcP.getFloatValue("exchange_rate"));
					}
				  %>
                  <td colspan="2" align="right" class="style1"><input name="contract_price_value" type="text" id="contract_price_value" value=<%=Utils.numberToStr(CntValue,3,false)%> style="width:140px" readonly="true"></td>
                </tr>
                <tr>
                  <td height="30" align="right" class="style1">Contract Price Fixation Status </td>
                  <td align="center" class="style1">:</td>
				  <%
				  	String ContractPriceStatus = "";
					String LblPyt ="";
					float RTon =0;
					float PTon =0;
					
					RTon = rc.getFloatValue("receive_tons");
					PTon = rc.getFloatValue("pending_tons");	
					float FTon = rc.getFloatValue("fixed_tons");
					float UFTon = rc.getFloatValue("unfixed_tons");
					
					if (UFTon==0) ContractPriceStatus = "F.Fixed";
					if (FTon==0) ContractPriceStatus = "F.UnFixed";
					if ((UFTon!=0) && (FTon!=0)) ContractPriceStatus = "P.Fixed";

					if (UFTon==0) 
					{
						if (PTon > 0) LblPyt = "Payment";
						if (PTon == 0) LblPyt = "Payment";
					}
					
					if (FTon==0) LblPyt = "Provisional Payment";
					if ((UFTon!=0) && (FTon!=0)) LblPyt = "Provisional Payment";	
					if (FTon == rc.getFloatValue("tons")) LblPyt = "Payment";
				  %>
                  <td colspan="2" align="right"><input name="fixation_status" type="text" id="fixation_status" value=<%=ContractPriceStatus%> style="width:140px" readonly="true"></td>
                </tr>
                <tr>
                  <td height="27">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
				<%
					if (rc.getFloatValue("unfixed_tons") > 0)
					{
				%>
                <tr>
                  <td height="31" align="right" class="style1">Provisional Price % Fixed For The Contract </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="provisional_price_percentage" type="text" id="provisional_price_percentage" value=<%=Utils.numberToStr(rc.getFloatValue("provisional_price_percentage"),3)%> style="width:140px" readonly="true">                    </td>
                </tr>

                <tr>
                  <td height="30" align="right" class="style1">Market Level On Date Of Delivery </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="market_price" type="text" id="market_price" value="<%=pMrkPrice%>" style="width:140px" onChange="doCalPrvPrice();"></td>
                </tr>
				
                <tr>
                  <td align="right" class="style1">Contract Differential </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="differential" type="text" id="differential" value=<%=Utils.numberToStr(rc.getFloatValue("differential"),3)%> style="width:140px" readonly="true" onChange="doCalPrvPrice();">                    </td>
                </tr>
                <tr>
                  <td height="30" align="right" class="style1">Market Price Less Differential </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right"><span class="style1">
				  <% 
				  	float MrkPriceLessDiff =0;
				   	MrkPriceLessDiff = pMrkPrice - pDiff;
				  %>
                    <input name="net_mrk_price" type="text" id="net_mrk_price" value=<%=MrkPriceLessDiff%> style="width:140px" readonly="true" onChange="doCalPrvPrice();">
                  </span></td>
                </tr>
			
                <tr>
                  <td height="30" align="right" class="style1">Provisional Price </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right"><span class="style1">
                    <input name="provisional_price" type="text" id="provisional_price" value=<%=pPrvPrice%> style="width:140px" readonly="true">
                  </span></td>
                </tr>
				<%
				}
				%>
                <tr>
                  <td height="30">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td height="30" align="right" class="style1"><%=lblPhyDiscTonValue%> </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="discount_mt" type="text" id="discount_mt" value="<%=pPhysDiscMt%>" style="width:140px"></td>
                </tr>
                <tr>
                  <td height="29" align="right" class="style1"><%=lblPhyDiscValue%></td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right" class="style1"><input name="physical_discount" type="text" id="physical_discount" value="<%=pPhysDiscV%>" style="width:140px"></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td class="style4">Other Discounts </td>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
								
                <tr>
                  <td height="33" align="right" class="style1"><%=lblCupDiscTonValue%></td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right"><span class="style1">
                    <input name="cuptest_discount" type="text" id="cuptest_discount" value="<%=pCupTest%>" style="width:140px" onChange="doCalPrvPrice();">
                  </span></td>
                </tr>
                <tr>
                  <td height="33" align="right" class="style1"><%=lblStkDiscTonValue%></td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right"><span class="style1">
                    <input name="storage_discount" type="text" id="storage_discount" value="<%=pStorage%>" style="width:140px" onChange="doCalPrvPrice();">
                  </span></td>
                </tr>
                <tr>
                  <td height="33" align="right" class="style1"><%=lblIntDiscTonValue%></td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right"><span class="style1">
                    <input name="interest_discount" type="text" id="interest_discount" value="<%=pInt%>" style="width:140px" onChange="doCalPrvPrice();">
                  </span></td>
                </tr>
                <tr>
                  <td height="32" align="right" class="style1"><%=lblOthDiscTonValue%> </td>
                  <td align="center" class="style1">:</td>
                  <td colspan="2" align="right"><span class="style1">
                    <input name="other_discount" type="text" id="other_discount" value="<%=pOth%>" style="width:140px" onChange="doCalPrvPrice();">
                  </span></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>

                <tr>
                  <td align="left" class="style4"><%=lblTotDiscValue%></td>
                  <td align="center" class="style4">:</td>
                  <td colspan="2" align="right"><span class="style1">
                    <input name="total_discount" type="text" id="total_discount" value="<%=pTotDisc%>" style="width:140px">
                  </span></td>
                </tr>
                <tr>
                  <td align="right" class="style4"><span class="style3"><span class="style1">
                  </span></span></td>
                  <td align="center" class="style4">&nbsp;</td>
                  <td colspan="2" align="right" class="style4"><span class="style1">
                  </span></td>
                </tr>

                <tr>
                  <td height="36" align="left" class="style4"><%=LblPyt%><span class="style3"><span class="style1">
                    <input name="payment_type" type="hidden" id="payment_type" value="<%=LblPyt%>">
                  </span></span></td>
                  <td align="center" class="style4">:</td>
                  <td colspan="2" align="right" class="style4"><span class="style1">
                    <input name="amount_paid" type="text" id="amount_paid" value="<%=pPaid%>" style="width:140px">
                  </span></td>
                </tr>

                <tr>
                  <td height="32" align="left" class="style4">&nbsp;</td>
                  <td align="center" class="style4">&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                </tr>
                <tr>
                  <td height="32" align="left" class="style4"><u>PAID SO FAR</u> </td>
                  <td align="center" class="style4">&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                </tr>
                <tr>
                  <td height="32" align="left" class="style4"><%=lblTotPaidForCntValue%></td>
                  <td align="center" class="style4">:</td>
                  <td colspan="2" align="right" class="style4"><span class="style1">
                    <input name="total_cnt_amt_paid" type="text" id="total_cnt_amt_paid" value="<%=Utils.numberToStr(task.getTotalPaidAmt(),2,false)%>" style="width:140px">
                  </span></td>
                </tr>
                <tr>
                  <td align="right" class="style4">&nbsp;</td>
                  <td align="center" class="style4">&nbsp;</td>
                  <td colspan="2" align="right" class="style4">&nbsp;</td>
                </tr>
                <tr>
                  <td align="left" class="style4"> <span class="style3"><span class="style1"><%=lblTotDiscForCntValue%>
                  </span></span></td>
                  <td align="center" class="style4"> :</td>
                  <td colspan="2" align="right" class="style4"><span class="style1">
                    <input name="total_cnt_discount" type="text" id="total_cnt_discount" value="<%=Utils.numberToStr(task.getTotalDiscount(),2,false)%>" style="width:140px">
                  </span></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td align="center" valign="middle">&nbsp;</td>
                  <td colspan="2" align="center">
				  	<img src="images/update.gif" width="15" height="15" onClick="doUpdatePay();">
				  </td>
                </tr>
              </table></td>
              </tr>
          </table></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="right"><img src="images/final_payment.jpg" width="55" height="18" onClick="doFinal();">&nbsp;<img src="images/listview.jpg" width="55" height="18" onClick="doListView();">&nbsp;<img src="images/report.jpg" width="55" height="18" onClick="doPricConfirmRpt();"></td>
    </tr>
  </table>
 <script>
 	doCalPrvPrice();
 </script>
  
</form>
<%@include file="../footer.jsp"%>
